package com.kwm.Controller;


import com.kwm.Service.impl.EmpServiceimpl;
import com.kwm.entity.Emp;
import com.kwm.entity.LoginEmp;
import com.kwm.entity.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class LoginController {

    @Autowired
    private EmpServiceimpl empServiceimpl;

    @PostMapping("/login")
    public Result Login(@RequestBody Emp emp) {
        log.info("员工登录{}", emp);
        LoginEmp e = empServiceimpl.Login(emp);
        if (e == null) {
            return Result.error("账号或密码错误");
        }

        return Result.success(e);
    }
}
